package 面试相关;

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        sc.nextLine();
        String s=sc.nextLine();
        System.out.println(func(a,s));

    }
    public static long func(int a[],String s){
        long ans=0;
        char[] color=s.toCharArray();
        HashMap<Integer,Integer> Rmap=new HashMap<>();
        HashMap<Integer,Integer> Bmap=new HashMap<>();
        for (int i = 0; i < a.length; i++) {
            if(color[i]=='R'){
                Rmap.put(a[i],Rmap.getOrDefault(a[i],0)+1);
            }else{
                Bmap.put(a[i],Bmap.getOrDefault(a[i],0)+1);
            }
        }
        for (int key : Rmap.keySet()) {
            if(Bmap.containsKey(key)){
                ans+=(long)Rmap.get(key)*(long)Bmap.get(key);
            }

        }
        return ans;
    }
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(),i = 0,res = 0;
        int[] nums = new int[n];
        while (i < n){
            nums[i] = scanner.nextInt();
            i++;
        }
        scanner.nextLine();
        String s = scanner.nextLine();
        for(int p = 0; p < n; p++){
            for(int q = p + 1; q < n; q++){
                if(nums[p] == nums[q]){
                    if(s.charAt(p) != s.charAt(q)){
                        res++;
                    }
                }
            }
        }
        System.out.println(res);
    }*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t > 0){
            int m = scanner.nextInt();
            int n = scanner.nextInt();
            int[][] nums = new int[m][n];
            for(int i = 0; i < m; i++){
                for(int j = 0; j < n; j++){
                    nums[i][j] = scanner.nextInt();
                }
            }
            fun(nums);
            t--;
        }
    }
    public static void fun(int[][] nums){
        int count = 0;
        int[][] res = new int[nums.length][nums[0].length];
        for(int i = 0; i < nums.length; i++){
            for(int j = 0; j < nums[0].length; j++){
                if(nums[i][j] == 1){
                    if((i - 1 > 0 && nums[i - 1][j] == 0)){
                        count++;
                    }
                    if((i + 1 < nums.length && nums[i + 1][j] == 0)){
                        count++;
                    }
                    if(j - 1 > 0 && nums[i][j - 1] == 0) {
                        count++;
                    }
                    if(j + 1 < nums[0].length && nums[i][j + 1] == 0){
                        count++;
                    }
                    if(count >= 2){
                        res[i][j] = 0;
                    }else{
                        res[i][j] = 1;
                    }
                }else{
                    res[i][j] = 0;
                }
                System.out.print(res[i][j]);
            }
            System.out.println();
        }
    }*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        for(int i = 0; i < 10; i++){
            int res = num*10 + i;
            if(res % 7 == 0){
                System.out.println(res);
                return;
            }
        }
    }*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        scanner.nextLine();
        String s = scanner.nextLine();
        int[] flag = new int[26];
        int res = 0;
        int len = 0;
        int max = 0;
        int i = 0,j = 0;
        while (j < s.length()){
            char c = s.charAt(j);
            if(flag[c - 'a' + 0] == 0){
                flag[c - 'a' + 0]++;
                res++;
            }else{

            }
        }
        System.out.println(max);
    }*/


    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int n = s.length();
        int[] nums = new int[n];
        for(int i = 0; i < n; i++){
            nums[i] = Integer.parseInt(s.substring(i,i+1));
        }
        Map<Integer,Integer> map = new HashMap<>();
        Map<Integer,ArrayList<int[]>> ans = new HashMap<>();
        map.put(-1,0);
        int pre = -1;
        for(int i = 0; i < n; i++){
            pre += (nums[i] == 0 ? -1 : 1);
            if(map.containsKey(pre)){
                int tem = i + 1 - map.get(pre);
                List<int[]> list = ans.getOrDefault(tem,new ArrayList<int[]>());
                list.add(new int[]{map.get(pre), i+1});
                ans.put(tem,(ArrayList<int[]>) list);
            }else{
                map.put(pre,i+1);
            }
        }
        int len = 0;
        for(int l : ans.keySet()){
            if(ans.get(l).size() < 2){
                continue;
            }
            len = Math.max(len, l);
        }
        List<int[]> arr = ans.get(len);
        for(int i = 0; i < 2; i++){
            int[] a = arr.get(i);
            System.out.println(a[0]);
            System.out.println(a[1]);
        }

    }*/
   /* public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int num1 = 0,num2 = 0,num3 = 0,num4 = 0;
        int max = 0;
        int a,b,c,d;
        for(int i = 0; i < s.length(); i++){
            for(int j = 0; j < s.length(); j++){
                for(int p = i + 1; p < s.length(); p++){
                    for(int q = j + 1; q < s.length(); q++){
                        if (s.charAt(j) == '1'){
                            num1++;
                        }else if(s.charAt(j) == '0'){
                            num2++;
                        }
                        if (s.charAt(q) == '1'){
                            num3++;
                        }else if(s.charAt(q) == '0'){
                            num4++;
                        }
                        if(num1 == num3 && num2 == num4){
                            if(max < (j - i)){
                                max = (j - i);
                                a = i;
                                b = j;
                                c = p;
                                d = q;
                            }
                        }
                    }
                }
                num1 = 0;
                num2 = 0;
                num3 = 0;
                num4 = 0;
            }
        }
        System.out.print(num1 + " " + num2 + " " + num3 + " " + num4);
    }*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        int[][] array = new int[m][m];
        int[][] new_array = new int[m * k][m * k];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < m; j++){
                array[i][j] = scanner.nextInt();
                for(int p = 0; p < k; p++){
                    for(int q = 0; q < k; q++){
                        new_array[i*k + p][j*k + q] = array[i][j];
                    }
                }
            }
        }
        for(int i = 0; i < m*k; i++){
            for(int j = 0; j < m*k; j++){
                System.out.print(new_array[i][j] + " ");
            }
            System.out.println();
        }

    }*/
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        scanner.nextLine();
        String b = scanner.nextLine();
        int[] a_arr = new int[b.length()];
        for(int i = 0; i < b.length(); i++) {
            char c = b.charAt(i);
            if (c == '1') {
                if (i + k < a_arr.length) {
                    a_arr[i + k] = 1;
                }else if (i >= k){
                    a_arr[i - k] = 1;
                }
            }
        }
        for(int c : a_arr){
            System.out.print(c);
        }
    }*/
  /*public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int num = scanner.nextInt();
      while (num > 0){
          int n = scanner.nextInt();
          int k = scanner.nextInt();
          scanner.nextLine();
          String s = scanner.nextLine();
          if (n % k != 0){
              System.out.println(-1);
          }else {
              fun(n,k,s);
          }
      }

  }
    public static void fun(int n, int k ,String s){
        int[] dp = new int[26];
        int[] flag = new int[6];
        int max = 0;
        for(int i = 0; i < s.length(); i++){
            dp[s.charAt(i) - 'a' + 0]++;
//            max = dp[s.charAt(i) - 'a' + 0] > max ? dp[s.charAt(i) - 'a' + 0] : max;
        }
        for(int i = 0; i < n; i++){
            if (dp[i] % k != 0){
                int dev = dp[i] % k;
                for(int j = n - 1; j > 0; j++){
                    if (dp[j] % k != 0){

                    }
                }
            }
        }

    }*/
}
